<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link th:href="@{/erp/assets/css/bootstrap.min.css}" rel="stylesheet"/>
    <link rel="stylesheet" th:href="@{/erp/css/style.css}"/>
    <link th:href="@{/erp/assets/css/codemirror.css}" rel="stylesheet">
    <link rel="stylesheet" th:href="@{/erp/assets/css/ace.min.css}"/>
    <link rel="stylesheet" th:href="@{/erp/assets/css/font-awesome.min.css}"/>
    <script th:src="@{/erp/assets/js/jquery.min.js}"></script>
    <script th:src="@{/erp/assets/js/bootstrap.min.js}"></script>
    <!-- page specific plugin scripts -->
    <script th:src="@{/erp/assets/js/jquery.dataTables.min.js}"></script>
    <script th:src="@{/erp/assets/js/jquery.dataTables.bootstrap.js}"></script>
    <script th:src="@{/erp/assets/layer/layer.js}" type="text/javascript"></script>
    <title>货架管理</title>
</head>
<body>
<form>
    <!--编辑区域分配图层-->
    <div class="edit_menber" id="edit_menber_style">
        <input th:value="${param.warehouseId}" id="iid" type="hidden">
        <input th:value="${param.areaId}" id="iid2" type="hidden">
        <input th:value="${param.id}" name="id" type="hidden">
        <ul class=" page-content">
            <div class="Operate_cont clearfix">
                <div class="brand_detailed">
                    <ul class="Info_style clearfix" style="width:510px; margin-top:0px;">
                        <li><label class="label_name">货架编号：</label>
                            <span class="name">
                                <input name="shelfNo"  required th:value="${param.shelfNo}" type="text"
                                       class="text_add"
                                       style="width:140px;"
                                       value="12014">
                            </span>
                        </li>
                        <li><label class="label_name">所属仓库：</label>
                            <span class="name">
                                 <!--下拉框-->
                                <select name="warehouseId" required onchange="getAreaByWid()" id="warehouseName" style="margin-left:10px;">
                                    <option value="" selected disabled>--请选择仓库--</option>
                                </select>
                            </span>
                        </li>
                        <li><label class="label_name">所属货区：</label>
                            <span class="name">
                               <select name="areaId" required id="areaName" style="margin-left:10px;">
                                    <option value="" selected disabled>--请选择货区--</option>
                                </select>
                            </span>
                        </li>
                       <!-- <li><label class="label_name">货区编号：</label>
                            <span class="name">
                                <input name="" type="text"
                                       class="text_add"
                                       style="width:140px;"
                                       >
                            </span>
                        </li>-->
                        <li><label class="label_name">负责人：</label>
                            <span class="name">
                            <input name="" readonly th:value="${param.warehousePerson}" type="text"
                                   class="text_add" style="width:140px;" >
                             </span>
                        </li>
                        <li><label class="label_name">联系电话：</label>
                            <span class="name">
                            <input name="" type="text" readonly th:value="${param.personTel}" class="text_add"
                                   style="width:140px;" >
                        </span>
                        </li>
                        <li><label class="label_name">主要商品：</label>
                            <span class="name" >
                                <input name="product" required th:value="${param.product}"  type="text" class="text_add" style="width:140px;">
                            </span>
                        </li>
                       <!-- <li><label class="label_name">货位数目：</label>
                            <span class="name">
                                <input name="" type="text"
                                                      class="text_add"
                                                      style="width:140px;"
                                                      value="1464">
                            </span>
                        </li>
                        <li><label class="label_name">空置货位：</label>
                            <span class="name">
                                <input name="" type="text"
                                                      class="text_add"
                                                      style="width:140px;"
                                                      value="1000">
                            </span>
                        </li>-->
                        <li><label class="label_name">创建时间：</label>
                            <span class="name" th:text="${param.createTime}"></span></li>
                        <li><label class="label_name">状态：</label>
                            <span class="name" th:if="${param.shelfStatus[0]} eq '1' ">
                            <input type="radio" th:value="1" checked class="input-text" placeholder=""
                                   name="shelfStatus">满货&nbsp;&nbsp;&nbsp;
                           <input type="radio" th:value="2" class="input-text" placeholder=""
                                  name="shelfStatus">未满
                        </span>
                            <span class="name" th:if="${param.shelfStatus[0]} eq '2' ">
                            <input type="radio" th:value="1" class="input-text" placeholder=""
                                   name="shelfStatus">满货&nbsp;&nbsp;
                           <input type="radio" checked th:value="2" class="input-text" placeholder=""
                                  name="shelfStatus">未满
                        </span>
                        <li class="b_Introduce"><label class="label_name">仓库描述：</label><br/>
                        <span class="name">
                            <textarea name="shelfRemark" required th:text="${param.shelfRemark}"
                                cols="40" rows="8"></textarea></span>
                        </li>
                        <div class="" style=" text-align:center">
                            <input class="btn btn-primary" id="tijiao" type="submit" value="提交">
                            <input class="btn btn-primary" id="tijiao1" type="reset" value="取消">
                        </div>
                    </ul>
                </div>
            </div>
        </ul>
    </div>
</form>

<script>

    jQuery(function ($) {
        var iid = $("#iid").val();
        var iid2 = $("#iid2").val();
        $.ajax({
            url: '/warehouse/list',
            type: 'post',
            success: function (res) {
                for (var i = 0; i < res.length; i++) {
                    if (iid == res[i].id) {
                        $("#warehouseName").append('<option selected value="' + res[i].id + '">' + res[i].warehouseName + '</option>')
                    } else {
                        $("#warehouseName").append('<option  value="' + res[i].id + '">' + res[i].warehouseName + '</option>')
                    }
                }
            }
        })

        $.post("/area/listByWid", {warehouseId: iid}, function (res) {
            for (var i = 0; i < res.length; i++) {
                if (iid2 == res[i].id) {
                    $("#areaName").append('<option selected value="' + res[i].id + '">' + res[i].areaName + '</option>')
                } else {
                    $("#areaName").append('<option  value="' + res[i].id + '">' + res[i].areaName + '</option>')
                }
            }
        })

        $('form').submit(function () {
            var data = $('form').serialize();
            $.ajax({
                url: '/shelf/update',
                type: 'post',
                data: data,
                success: function (res) {
                    if (res.rs) {
                        parent.layer.msg(res.msg, {icon: 1});
                        $('#btn',parent.window.document).click();
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                    } else {
                        layer.msg(res.msg, {icon: 2});
                    }
                }
            })
            return false;
        });

        $('#tijiao1').on('click', function () {
            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            parent.layer.close(index); //再执行关闭
        });
    });

    //仓库联动库区
    function getAreaByWid() {
        var wId = $("#warehouseName").find("option:selected").val();
        $("#areaName").empty();
        $.post("/area/listByWid", {warehouseId: wId}, function (mydata) {
            $("#areaName").append('<option value="" selected disabled>--请输入货区--</option>');
            for (var i = 0; i < mydata.length; i++) {
                $("#areaName").append('<option value="' + mydata[i].id + '">' + mydata[i].areaName + '</option>')
            }
        });
        return false;
    }

</script>


</body>
</html>


